Relative
The Relative reference form specifies an object or a location by describing its position in relation to another object, known as the base, in the same container.SYNTAX
[ className ] ( before | [in] front of ) baseReference [ className ] ( after | [in] back of | behind ) baseReferencewhereclassName is the class identifier of the specified object. If you leave out this parameter, AppleScript assumes you want an insertion point.
baseReference is a reference to the base object.
The
before
andin front of
forms, which are equivalent, refer to the object immediately preceding the base object. Theafter,
in back of,
andbehind
forms are equivalent and refer to the object immediately after the base.EXAMPLES
The following references specify the word immediately before the first figure.
word before figure 1 word in front of figure 1The following examples specify the insertion point immediately before the tenth paragraph.
before paragraph 10 in front of paragraph 10The following example contains three references. The first two are Index references that specify the front document and the first word. The third
is a Relative reference that specifies the insertion point before the tenth paragraph. The command moves the first word to the insertion point
before the tenth paragraph.
tell front document of application "Scriptable Text Editor" move word 1 to before paragraph 10 end tellNOTES
You can specify only a single object with the Relative form. You can use the form to specify an object that is either before or after the base object.If it is possible for the specified object to contain the base object (as in the expression
paragraph before word 99
), the reference does not specify
the container but instead specifies the object immediately before or after the container of the base object. For example, the expressionparagraph before word 99
specifies the paragraph immediately before the paragraph containing the ninety-ninth word.All applications allow you to specify a base object belonging to the same
class as the desired object (such aswindow in back of window "Big"
). Not all allow you to specify a base of a different object class (such asword before figure 1
). The possible base classes for a particular class are up
to each application.